import { ref, computed } from 'vue'
import dayjs from 'dayjs'
// 格式化时间
export function useCountDown() {
    const time = ref(0)
    // 时间格式 xx分xxx秒
    const formatTime = computed(() => dayjs.unix(time.value).format('mm分ss秒'))
    // 每隔一秒-1
    const start = (currentTime) => {
        time.value = currentTime
        setInterval(() => {
            time.value--
        }, 1000)
    }

    return {
        formatTime,
        start
    }
}